package com.rimi.util;


import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * @author liHaiYang
 * @version V1.0
 * @Description: (用一句话描述该文件做什么)
 * @date 2021/7/1 15:16
 */
public class PwdUtil {

    private static String alogorithmName = "md5";

    private static Integer hashIterations = 10;

    private static Object salt = "j2101";

    public static ByteSource salt(){
      return   ByteSource.Util.bytes(salt);
    }

    /**
     * 加密
     * @param password
     * @return
     */
    public static String encode(String password){
        SimpleHash simpleHash = new SimpleHash(alogorithmName,password,salt,hashIterations);
        return simpleHash.toHex();
    }

    public static void main(String[] args) {
        String encode = PwdUtil.encode("123");
        System.out.println(encode);
    }
}
